﻿package com.xeem.core.components
{
	
	/**
	 * 简单按钮适配器
	 * @author harrihuang
	 * @email harrihuang@live.cn
	 * @version 1.0
	 * @fp version 9+
	 */
	
	import flash.display.MovieClip;
	import flash.events.MouseEvent;
	
	public class SimpleButton extends BaseComponent
	{
		private var strip_MouseDown:String="mouseDown";
		private var strip_MouseUp:String="mouseUp";
		private var strip_MouseOver:String="mouseOver";
		private var strip_MouseOut:String="mouseOut";
		private var strip_MouseClick:String="mouseClick";
		
				
		public function SimpleButton() 
		{
			stop();
			this.buttonMode=true;
			this.addEventListener(MouseEvent.MOUSE_DOWN, onDown);
			this.addEventListener(MouseEvent.MOUSE_UP, onUp);
			this.addEventListener(MouseEvent.MOUSE_OVER,onOver);
			this.addEventListener(MouseEvent.MOUSE_OUT,onOut);
			this.addEventListener(MouseEvent.CLICK,onClick);				
		}
		
		public function removeMouseEvent(ary:Array){
			for (var i=0;i<ary.length;i++){
					switch (ary[i]){
						case MouseEvent.MOUSE_DOWN: 
							this.removeEventListener(MouseEvent.MOUSE_DOWN, onDown);
							break;
						case MouseEvent.MOUSE_UP:
							this.removeEventListener(MouseEvent.MOUSE_UP,onUp);
							break;
						case MouseEvent.MOUSE_OVER:
							this.removeEventListener(MouseEvent.MOUSE_OVER,onOver);
							break;
						case MouseEvent.MOUSE_OUT:
							this.removeEventListener(MouseEvent.MOUSE_OUT,onOut);
							break;
						case MouseEvent.CLICK:
							this.removeEventListener(MouseEvent.CLICK,onClick);
							break;
						default:
							break;
					}
			}
		}
		
		private function onDown(e:MouseEvent):void 
		{
			this.Status=MouseEvent.MOUSE_DOWN;
			trace(strip_MouseDown);
			if (null!=strip_MouseDown){
				if (strip_MouseDown!="")
					this.gotoAndPlay(strip_MouseDown);
			}				
		}
		
		private function onUp(e:MouseEvent):void 
		{
			this.Status=MouseEvent.MOUSE_UP;
			trace(strip_MouseUp);
			if (null!=strip_MouseUp){
				if (strip_MouseUp!="")
					this.gotoAndPlay(strip_MouseUp);
			}
		}
		
		private function onOver(e:MouseEvent):void{
			trace(strip_MouseOver);
			if (null!=strip_MouseOver){
				this.gotoAndPlay(strip_MouseOver);
			}
		}
		
		private function onOut(e:MouseEvent):void{
			trace(strip_MouseOut);
			if (null!=strip_MouseOut){
				this.gotoAndPlay(strip_MouseOut);
			}
		}
		
		private function onClick(e:MouseEvent):void{
			trace(strip_MouseClick);
			if (null!=strip_MouseClick){
				this.gotoAndPlay(strip_MouseClick);
			}
		}
		
		public function set stripMouseUp(str:String){
			strip_MouseUp=str;
		}
		
		public function set stripMouseDown(str:String){
			strip_MouseDown=str;
		}
		
		public function set stripMouseOver(str:String){
			strip_MouseOver=str;
		}
		
		public function set stripMouseOut(str:String){
			strip_MouseOut=str;
		}
		
		public function set stripMouseClick(str:String){
			strip_MouseClick=str;
		}
	}
}